Execute DDL Statement in MySQL
Let’s see how we can Execute DDL Statement in MySQL using the DB connector in MuleSoft.
Create a project in Anypoint Studio

Add the HTTP listener and flow to get the request for executing DDL statement

Drag and Drop Execute DDL activity in a flow

Create a MySQL connection by following the steps mentioned in the Connect with MySQL DB through MuleSoft

Paste the required DDL in SQL Query Text – Remove the semicolon from the DDL statement
Example DDL
CREATE TABLE inventory (
id INT PRIMARY KEY,
product VARCHAR(50) UNIQUE,
quantity INT,
price DECIMAL(18,2)
)
Note – you can only provide the plain text as an input here and it can’t be changed to dynamic content e.g. getting the statement from the input payload

Set the response payload

Run the service

Test the endpoint in a browser
http://localhost:8081/execute-ddl

We can see the table in MySQL database

Sample Application – mysql-db-service
Sample SOAP UI project – MySQL-service-soapui-project